package cn.hy.创建型模式.工厂模式;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zhaomu
 */
public class FoodFactory {

    public static Food makeFood(String name) {
        if (name.equals("noodle")) {
            Food noodle = new LanZhouNoodle();
            noodle.addSpicy("more");
            return noodle;
        } else if (name.equals("chicken")) {
            Food chicken = new HuangMenChicken();
            chicken.addCondiment("potato");
            return chicken;
        } else {
            return null;
        }
    }

    static class Food {
        void addSpicy(String spicy){

        }
        void addCondiment(String condiment){

        }
    }

    static class LanZhouNoodle extends Food {
        private List<String> spicyList = new ArrayList<>();

        @Override
        public void addSpicy(String spicy) {
            spicyList.add(spicy);
        }
    }

    static class HuangMenChicken extends Food {

        @Override
        public void addCondiment(String condiment){

        }
    }
}